home *** CD-ROM | disk | FTP | other *** search
/ Holt Researcher: American History / Holt Researcher: American History.iso / pc / modules / grphwiz.dxr / 00151_table object.ls < prev    next >
Encoding:
Text File  |  2000-01-14  |  20.2 KB  |  675 lines

  1. property _me, pSelectChannel, pGrayChannel1, pGrayChannel2, pSelectionRect, pGrayRect1, pGrayRect2, pVSlider, pUpButton, pDownButton, pTracking, pEditCell, pEditField, pEditFieldChannel, pColumnIsVisible, pBody, pRowHeader, pColumnHeader, pCorner
  2. global gGraphWizard, gGraph
  3.  
  4. on new me, selectChannel, grayChannel1, grayChannel2, vSlider, upButton, downButton, fieldName, castName, fieldChannel, body, colHeader, rowHeader, corner, descendant
  5.   if objectp(descendant) then
  6.     _me = descendant
  7.   else
  8.     _me = me
  9.   end if
  10.   pSelectChannel = selectChannel
  11.   pGrayChannel1 = grayChannel1
  12.   pGrayChannel2 = grayChannel2
  13.   pVSlider = vSlider
  14.   pUpButton = upButton
  15.   pDownButton = downButton
  16.   pEditField = member(fieldName, castName)
  17.   pEditFieldChannel = fieldChannel
  18.   pBody = body
  19.   pRowHeader = rowHeader
  20.   pColumnHeader = colHeader
  21.   pCorner = corner
  22.   pSelectionRect = rect(-1, -1, -1, -1)
  23.   pGrayRect1 = rect(-1, -1, -1, -1)
  24.   pGrayRect2 = rect(-1, -1, -1, -1)
  25.   pTracking = 0
  26.   pEditCell = point(-1, -1)
  27.   return me
  28. end
  29.  
  30. on condemn me
  31.   _me = 0
  32.   return me
  33. end
  34.  
  35. on setSuperTable me
  36.   setSuperTable(pBody, _me)
  37.   setSuperTable(pRowHeader, _me)
  38.   setSuperTable(pColumnHeader, _me)
  39.   setSuperTable(pCorner, _me)
  40.   return me
  41. end
  42.  
  43. on setColumnIsVisible me, isVisible
  44.   pColumnIsVisible = isVisible
  45.   setIsVisible(pColumnHeader, isVisible)
  46.   setIsVisible(pCorner, isVisible)
  47.   return me
  48. end
  49.  
  50. on Inscope me
  51.   puppetSprite(pSelectChannel, 1)
  52.   puppetSprite(pGrayChannel1, 1)
  53.   puppetSprite(pGrayChannel2, 1)
  54.   puppetSprite(pEditFieldChannel, 1)
  55.   return me
  56. end
  57.  
  58. on outScope me
  59.   resetSelection(_me)
  60.   pEditCell = point(-1, -1)
  61.   puppetSprite(pSelectChannel, 0)
  62.   puppetSprite(pGrayChannel1, 0)
  63.   puppetSprite(pGrayChannel2, 0)
  64.   puppetSprite(pEditFieldChannel, 0)
  65.   return me
  66. end
  67.  
  68. on showMe me
  69.   set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  70.   set the rect of sprite pGrayChannel1 to getVisRect(_me, pGrayRect1)
  71.   set the rect of sprite pGrayChannel2 to getVisRect(_me, pGrayRect2)
  72.   updateStage()
  73.   return me
  74. end
  75.  
  76. on hideMe me
  77.   set the rect of sprite pSelectChannel to rect(0, 0, 0, 0)
  78.   set the rect of sprite pGrayChannel1 to rect(0, 0, 0, 0)
  79.   set the rect of sprite pGrayChannel2 to rect(0, 0, 0, 0)
  80.   updateStage()
  81.   return me
  82. end
  83.  
  84. on trackMouse me, startCell
  85.   pTracking = 1
  86.   resetSelection(me._me)
  87.   c = point(-1, -1)
  88.   currCell = startCell
  89.   setSelectionRect(me._me, startCell, currCell)
  90.   repeat while the mouseDown
  91.     currCell = getCurrCell(me._me, the mouseH, the mouseV)
  92.     if c <> currCell then
  93.       setSelectionRect(me._me, startCell, currCell)
  94.       set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  95.       updateStage()
  96.       c = currCell
  97.     end if
  98.   end repeat
  99.   setSelectionRect(me._me, startCell, currCell)
  100.   set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  101.   repeat with i in getCutCopyPasteList(gGraphWizard)
  102.     enable(i)
  103.   end repeat
  104.   updateStage()
  105.   pEditCell = startCell
  106.   showEditField(_me)
  107.   pTracking = 0
  108.   return me
  109. end
  110.  
  111. on getCurrCell me, h, v
  112.   if isAbove(pBody, v) then
  113.     if isLeftOf(pBody, h) then
  114.       if not minReached(pVSlider) then
  115.         simulateClickOn(pUpButton)
  116.         mouseCell = getMouseCell(pRowHeader, h, v)
  117.         currCell = point(0, getAt(mouseCell, 2))
  118.       else
  119.         if pColumnIsVisible then
  120.           currCell = point(0, 0)
  121.         else
  122.           currCell = point(0, 1)
  123.         end if
  124.       end if
  125.     else
  126.       if not minReached(pVSlider) then
  127.         simulateClickOn(pUpButton)
  128.         currCell = getMouseCell(pBody, h, v)
  129.       else
  130.         if pColumnIsVisible then
  131.           mouseCell = getMouseCell(pColumnHeader, h, v)
  132.           currCell = point(getAt(mouseCell, 1), 0)
  133.         else
  134.           currCell = getMouseCell(pBody, h, v)
  135.         end if
  136.       end if
  137.     end if
  138.   else
  139.     if not isBelow(pBody, v) then
  140.       if isLeftOf(pBody, h) then
  141.         mouseCell = getMouseCell(pRowHeader, h, v)
  142.         currCell = point(0, getAt(mouseCell, 2))
  143.       else
  144.         currCell = getMouseCell(pBody, h, v)
  145.       end if
  146.     else
  147.       if isLeftOf(pBody, h) then
  148.         if not maxReached(pVSlider) then
  149.           simulateClickOn(pDownButton)
  150.         end if
  151.         mouseCell = getMouseCell(pRowHeader, h, v)
  152.         currCell = point(0, getAt(mouseCell, 2))
  153.       else
  154.         if not maxReached(pVSlider) then
  155.           simulateClickOn(pDownButton)
  156.         end if
  157.         currCell = getMouseCell(pBody, h, v)
  158.       end if
  159.     end if
  160.   end if
  161.   return currCell
  162. end
  163.  
  164. on doRollover me
  165.   return me
  166. end
  167.  
  168. on scrollUp me
  169.   if not atTop(pBody) then
  170.     scrollUp(pBody)
  171.     scrollUp(pRowHeader)
  172.     set the rect of sprite pGrayChannel1 to getVisRect(_me, pGrayRect1)
  173.     set the rect of sprite pGrayChannel2 to getVisRect(_me, pGrayRect2)
  174.     if not pTracking then
  175.       set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  176.       if isEditCellVisible(_me) then
  177.         showEditField(_me)
  178.       else
  179.         hideEditField(_me)
  180.       end if
  181.     end if
  182.     updateStage()
  183.   end if
  184.   return me
  185. end
  186.  
  187. on scrollDown me
  188.   if not atBottom(pBody) then
  189.     scrollDown(pBody)
  190.     scrollDown(pRowHeader)
  191.     set the rect of sprite pGrayChannel1 to getVisRect(_me, pGrayRect1)
  192.     set the rect of sprite pGrayChannel2 to getVisRect(_me, pGrayRect2)
  193.     if not pTracking then
  194.       set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  195.       if isEditCellVisible(_me) then
  196.         showEditField(_me)
  197.       else
  198.         hideEditField(_me)
  199.       end if
  200.     end if
  201.     updateStage()
  202.   end if
  203.   return me
  204. end
  205.  
  206. on getTopRow me
  207.   return getTopRow(pBody)
  208. end
  209.  
  210. on getLeftColumn me
  211.   return getLeftColumn(pBody)
  212. end
  213.  
  214. on resetSelection me
  215.   hideEditField(_me)
  216.   pSelectionRect = rect(-1, -1, -1, -1)
  217.   set the rect of sprite pSelectChannel to rect(0, 0, 0, 0)
  218.   updateStage()
  219.   return me
  220. end
  221.  
  222. on setSelectionRect me, cell1, cell2
  223.   p1 = duplicate(cell1)
  224.   p2 = duplicate(cell2)
  225.   if getAt(p1, 1) > getAt(p2, 1) then
  226.     temp = getAt(p2, 1)
  227.     setAt(p2, 1, getAt(p1, 1))
  228.     setAt(p1, 1, temp)
  229.   end if
  230.   if getAt(p1, 2) > getAt(p2, 2) then
  231.     temp = getAt(p2, 2)
  232.     setAt(p2, 2, getAt(p1, 2))
  233.     setAt(p1, 2, temp)
  234.   end if
  235.   pSelectionRect = rect(p1, p2)
  236.   return me
  237. end
  238.  
  239. on getVisRect me, theRect
  240.   R = rect(0, 0, 0, 0)
  241.   if theRect <> rect(-1, -1, -1, -1) then
  242.     if (theRect.left > 0) and (theRect.top > 0) then
  243.       R = getVisRect(pBody, theRect)
  244.     end if
  245.     if (theRect.left = 0) and (theRect.top > 0) then
  246.       r1 = getVisRect(pRowHeader, rect(1, getAt(theRect, 2), 1, getAt(theRect, 4)))
  247.       r2 = getVisRect(pBody, rect(1, getAt(theRect, 2), getAt(theRect, 3), getAt(theRect, 4)))
  248.       R = unionVisRect(_me, r1, r2)
  249.     end if
  250.     if (theRect.left > 0) and (theRect.top = 0) then
  251.       r1 = getVisRect(pColumnHeader, rect(getAt(theRect, 1), 1, getAt(theRect, 3), 1))
  252.       r2 = getVisRect(pBody, rect(getAt(theRect, 1), 1, getAt(theRect, 3), getAt(theRect, 4)))
  253.       R = unionVisRect(_me, r1, r2)
  254.     end if
  255.     if (theRect.left = 0) and (theRect.top = 0) then
  256.       r1 = getVisRect(pCorner, rect(1, 1, 1, 1))
  257.       if (theRect.right = 0) and (theRect.bottom = 0) then
  258.         nothing()
  259.       else
  260.         if theRect.right = 0 then
  261.           r2 = getVisRect(pRowHeader, rect(1, getAt(theRect, 2), 1, getAt(theRect, 4)))
  262.         else
  263.           if theRect.bottom = 0 then
  264.             r2 = getVisRect(pColumnHeader, rect(getAt(theRect, 1), 1, getAt(theRect, 3), 1))
  265.           else
  266.             r2 = getVisRect(pBody, rect(1, 1, getAt(theRect, 3), getAt(theRect, 4)))
  267.             r3 = getVisRect(pRowHeader, rect(1, getAt(theRect, 2), 1, getAt(theRect, 4)))
  268.             r4 = getVisRect(pColumnHeader, rect(getAt(theRect, 1), 1, getAt(theRect, 3), 1))
  269.             r2 = unionVisRect(_me, r2, r3)
  270.             r2 = unionVisRect(_me, r2, r4)
  271.           end if
  272.         end if
  273.       end if
  274.       R = unionVisRect(_me, r1, r2)
  275.     end if
  276.   end if
  277.   return R
  278. end
  279.  
  280. on unionVisRect me, rect1, rect2
  281.   R = rect(0, 0, 0, 0)
  282.   if voidp(rect1) or (rect1 = rect(0, 0, 0, 0)) then
  283.     return rect2
  284.   else
  285.     if voidp(rect2) or (rect2 = rect(0, 0, 0, 0)) then
  286.       return rect1
  287.     else
  288.       return union(rect1, rect2)
  289.     end if
  290.   end if
  291. end
  292.  
  293. on setGrayRegion me, chartType
  294.   case chartType of
  295.     0:
  296.       pGrayRect1 = rect(2, 1, 5, 30)
  297.       pGrayRect2 = rect(0, 11, 1, 30)
  298.     1:
  299.       pGrayRect1 = rect(2, 1, 5, 30)
  300.       pGrayRect2 = rect(-1, -1, -1, -1)
  301.     2:
  302.       pGrayRect1 = rect(2, 1, 5, 25)
  303.       pGrayRect2 = rect(0, 26, 5, 30)
  304.     3:
  305.       pGrayRect1 = rect(0, 21, 5, 30)
  306.       pGrayRect2 = rect(-1, -1, -1, -1)
  307.     4:
  308.       pGrayRect1 = rect(0, 6, 5, 30)
  309.       pGrayRect2 = rect(-1, -1, -1, -1)
  310.   end case
  311.   return me
  312. end
  313.  
  314. on isNumberCell me
  315.   return (getAt(pEditCell, 1) > 0) and (getAt(pEditCell, 2) > 0)
  316. end
  317.  
  318. on isEditCellVisible me
  319.   if pEditCell <> point(-1, -1) then
  320.     if pEditCell = point(0, 0) then
  321.       cell = point(1, 1)
  322.       subtable = pCorner
  323.     else
  324.       if getAt(pEditCell, 1) = 0 then
  325.         cell = duplicate(pEditCell)
  326.         setAt(cell, 1, 1)
  327.         subtable = pRowHeader
  328.       else
  329.         if getAt(pEditCell, 2) = 0 then
  330.           cell = duplicate(pEditCell)
  331.           setAt(cell, 2, 1)
  332.           subtable = pColumnHeader
  333.         else
  334.           cell = pEditCell
  335.           subtable = pBody
  336.         end if
  337.       end if
  338.     end if
  339.     editRect = getCellRect(subtable, cell)
  340.     if not voidp(editRect) then
  341.       return isEditCellVisible(subtable, cell)
  342.     else
  343.       return 0
  344.     end if
  345.   else
  346.     return 0
  347.   end if
  348. end
  349.  
  350. on showEditField me
  351.   if pEditCell <> point(-1, -1) then
  352.     if pEditCell = point(0, 0) then
  353.       cell = point(1, 1)
  354.       subtable = pCorner
  355.     else
  356.       if getAt(pEditCell, 1) = 0 then
  357.         cell = duplicate(pEditCell)
  358.         setAt(cell, 1, 1)
  359.         subtable = pRowHeader
  360.       else
  361.         if getAt(pEditCell, 2) = 0 then
  362.           cell = duplicate(pEditCell)
  363.           setAt(cell, 2, 1)
  364.           subtable = pColumnHeader
  365.         else
  366.           cell = pEditCell
  367.           subtable = pBody
  368.         end if
  369.       end if
  370.     end if
  371.     editRect = getCellRect(subtable, cell)
  372.     theContents = getCellContents(subtable, cell)
  373.     member(pEditField).text = theContents
  374.     if not voidp(editRect) then
  375.       if isCellVisible(subtable, editRect) then
  376.         n = the number of chars in theContents
  377.         sprite(pEditFieldChannel).visible = 0
  378.         updateStage()
  379.         set the rect of sprite pEditFieldChannel to editRect
  380.         sprite(pEditFieldChannel).visible = 1
  381.         updateStage()
  382.         hilite char 1 to n of field pEditField
  383.       else
  384.         hideEditField(_me)
  385.       end if
  386.     else
  387.       hideEditField(_me)
  388.     end if
  389.   end if
  390.   return me
  391. end
  392.  
  393. on hideEditField me
  394.   if pEditCell <> point(-1, -1) then
  395.     if pEditCell = point(0, 0) then
  396.       cell = point(1, 1)
  397.       subtable = pCorner
  398.     else
  399.       if getAt(pEditCell, 1) = 0 then
  400.         cell = duplicate(pEditCell)
  401.         setAt(cell, 1, 1)
  402.         subtable = pRowHeader
  403.       else
  404.         if getAt(pEditCell, 2) = 0 then
  405.           cell = duplicate(pEditCell)
  406.           setAt(cell, 2, 1)
  407.           subtable = pColumnHeader
  408.         else
  409.           cell = pEditCell
  410.           subtable = pBody
  411.         end if
  412.       end if
  413.     end if
  414.     setCellContents(subtable, cell, member(pEditField).text)
  415.   end if
  416.   sprite(pEditFieldChannel).visible = 0
  417.   updateStage()
  418.   set the loc of sprite pEditFieldChannel to point(-9999, -9999)
  419.   sprite(pEditFieldChannel).visible = 1
  420.   updateStage()
  421.   return me
  422. end
  423.  
  424. on getBodyData me
  425.   return getData(pBody)
  426. end
  427.  
  428. on getData me
  429.   theData = []
  430.   if getaProp(gGraph, #pChartType) > 2 then
  431.     append(theData, getData(pCorner))
  432.     append(theData, getData(pColumnHeader))
  433.   end if
  434.   append(theData, getData(pRowHeader))
  435.   append(theData, getData(pBody))
  436.   return theData
  437. end
  438.  
  439. on setData me, theData
  440.   if getaProp(gGraph, #pChartType) > 2 then
  441.     setData(pCorner, getAt(theData, 1))
  442.     setData(pColumnHeader, getAt(theData, 2))
  443.     setData(pRowHeader, getAt(theData, 3))
  444.     setData(pBody, getAt(theData, 4))
  445.   else
  446.     setData(pRowHeader, getAt(theData, 1))
  447.     setData(pBody, getAt(theData, 2))
  448.   end if
  449.   return me
  450. end
  451.  
  452. on getColumnHeader me
  453.   return getData(pColumnHeader)
  454. end
  455.  
  456. on getRowHeader me
  457.   return getData(pRowHeader)
  458. end
  459.  
  460. on checkIfSelected me
  461.   return pSelectionRect <> rect(-1, -1, -1, -1)
  462. end
  463.  
  464. on checkPasteDataSize me, dataList
  465.   R = getAt(dataList, 1)
  466.   if pSelectionRect = rect(-1, -1, -1, -1) then
  467.     return 0
  468.   else
  469.     return ((R.right - R.left) <= (getNumColumns(pBody) - pSelectionRect.left)) and ((R.bottom - R.top) <= (getNumRows(pBody) - pSelectionRect.top))
  470.   end if
  471. end
  472.  
  473. on cutSelectedData me
  474.   hideEditField(_me)
  475.   if pSelectionRect <> rect(-1, -1, -1, -1) then
  476.     dataList = []
  477.     append(dataList, pSelectionRect)
  478.     if (pSelectionRect.left > 0) and (pSelectionRect.top > 0) then
  479.       append(dataList, cutSelectedData(pBody, pSelectionRect))
  480.     else
  481.       if (pSelectionRect.left > 0) and (pSelectionRect.top = 0) then
  482.         data = cutSelectedData(pColumnHeader, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), 1))
  483.         data = quickUnion(data, cutSelectedData(pBody, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4))))
  484.         append(dataList, data)
  485.       else
  486.         if (pSelectionRect.left = 0) and (pSelectionRect.top > 0) then
  487.           data = []
  488.           rowData = cutSelectedData(pRowHeader, rect(1, getAt(pSelectionRect, 2), 1, getAt(pSelectionRect, 4)))
  489.           bodyData = cutSelectedData(pBody, rect(1, getAt(pSelectionRect, 2), getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
  490.           numRows = getAt(pSelectionRect, 4) - getAt(pSelectionRect, 2) + 1
  491.           numCols = getAt(pSelectionRect, 3)
  492.           repeat with i = 1 to numRows
  493.             append(data, getAt(rowData, i))
  494.             repeat with j = 1 to numCols
  495.               append(data, getAt(bodyData, ((i - 1) * numCols) + j))
  496.             end repeat
  497.           end repeat
  498.           append(dataList, data)
  499.         else
  500.           data = cutSelectedData(pCorner, rect(1, 1, 1, 1))
  501.           data = quickUnion(data, cutSelectedData(pColumnHeader, rect(1, 1, getAt(pSelectionRect, 3), 1)))
  502.           rowData = cutSelectedData(pRowHeader, rect(1, 1, 1, getAt(pSelectionRect, 4)))
  503.           bodyData = cutSelectedData(pBody, rect(1, 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
  504.           numRows = getAt(pSelectionRect, 4)
  505.           numCols = getAt(pSelectionRect, 3)
  506.           repeat with i = 1 to numRows
  507.             append(data, getAt(rowData, i))
  508.             repeat with j = 1 to numCols
  509.               append(data, getAt(bodyData, ((i - 1) * numCols) + j))
  510.             end repeat
  511.           end repeat
  512.           append(dataList, data)
  513.         end if
  514.       end if
  515.     end if
  516.   end if
  517.   showEditField(_me)
  518.   return dataList
  519. end
  520.  
  521. on getSelectedData me
  522.   hideEditField(_me)
  523.   if pSelectionRect <> rect(-1, -1, -1, -1) then
  524.     dataList = []
  525.     append(dataList, pSelectionRect)
  526.     if (pSelectionRect.left > 0) and (pSelectionRect.top > 0) then
  527.       append(dataList, getSelectedData(pBody, pSelectionRect))
  528.     else
  529.       if (pSelectionRect.left > 0) and (pSelectionRect.top = 0) then
  530.         data = getSelectedData(pColumnHeader, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), 1))
  531.         data = quickUnion(data, getSelectedData(pBody, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4))))
  532.         append(dataList, data)
  533.       else
  534.         if (pSelectionRect.left = 0) and (pSelectionRect.top > 0) then
  535.           data = []
  536.           rowData = getSelectedData(pRowHeader, rect(1, getAt(pSelectionRect, 2), 1, getAt(pSelectionRect, 4)))
  537.           bodyData = getSelectedData(pBody, rect(1, getAt(pSelectionRect, 2), getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
  538.           numRows = getAt(pSelectionRect, 4) - getAt(pSelectionRect, 2) + 1
  539.           numCols = getAt(pSelectionRect, 3)
  540.           repeat with i = 1 to numRows
  541.             append(data, getAt(rowData, i))
  542.             repeat with j = 1 to numCols
  543.               append(data, getAt(bodyData, ((i - 1) * numCols) + j))
  544.             end repeat
  545.           end repeat
  546.           append(dataList, data)
  547.         else
  548.           data = getSelectedData(pCorner, rect(1, 1, 1, 1))
  549.           data = quickUnion(data, getSelectedData(pColumnHeader, rect(1, 1, getAt(pSelectionRect, 3), 1)))
  550.           rowData = getSelectedData(pRowHeader, rect(1, 1, 1, getAt(pSelectionRect, 4)))
  551.           bodyData = getSelectedData(pBody, rect(1, 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
  552.           numRows = getAt(pSelectionRect, 4)
  553.           numCols = getAt(pSelectionRect, 3)
  554.           repeat with i = 1 to numRows
  555.             append(data, getAt(rowData, i))
  556.             repeat with j = 1 to numCols
  557.               append(data, getAt(bodyData, ((i - 1) * numCols) + j))
  558.             end repeat
  559.           end repeat
  560.           append(dataList, data)
  561.         end if
  562.       end if
  563.     end if
  564.   end if
  565.   showEditField(_me)
  566.   return dataList
  567. end
  568.  
  569. on setSelectedData me, dataList
  570.   hideEditField(_me)
  571.   theRect = getAt(dataList, 1)
  572.   R = rect(-1, -1, -1, -1)
  573.   R.left = pSelectionRect.left
  574.   R.top = pSelectionRect.top
  575.   R.right = pSelectionRect.left + (theRect.right - theRect.left)
  576.   R.bottom = pSelectionRect.top + (theRect.bottom - theRect.top)
  577.   numRows = R.bottom - R.top + 1
  578.   numCols = R.right - R.left + 1
  579.   data = getAt(dataList, 2)
  580.   if (R.left > 0) and (R.top > 0) then
  581.     setSelectedData(pBody, R, data)
  582.   else
  583.     if (R.left > 0) and (R.top = 0) then
  584.       colData = getSubList(data, 1, numCols)
  585.       setSelectedData(pColumnHeader, rect(getAt(R, 1), 1, getAt(R, 3), 1), colData)
  586.       bodyData = getSubList(data, numCols + 1, count(data))
  587.       setSelectedData(pBody, rect(getAt(R, 1), 1, getAt(R, 3), getAt(R, 4)), bodyData)
  588.     else
  589.       if (R.left = 0) and (R.top > 0) then
  590.         rowData = []
  591.         bodyData = []
  592.         repeat with i = 1 to numRows
  593.           append(rowData, getAt(data, (numCols * (i - 1)) + 1))
  594.           bodyData = quickUnion(bodyData, getSubList(data, (numCols * (i - 1)) + 2, numCols * i))
  595.         end repeat
  596.         setSelectedData(pRowHeader, rect(1, getAt(R, 2), 1, getAt(R, 4)), rowData)
  597.         setSelectedData(pBody, rect(1, getAt(R, 2), getAt(R, 3), getAt(R, 4)), bodyData)
  598.       else
  599.         setSelectedData(pCorner, rect(1, 1, 1, 1), getSubList(data, 1, 1))
  600.         colData = getSubList(data, 2, numCols)
  601.         setSelectedData(pColumnHeader, rect(1, 1, getAt(R, 3), 1), colData)
  602.         rowData = []
  603.         bodyData = []
  604.         repeat with i = 2 to numRows
  605.           append(rowData, getAt(data, (numCols * (i - 1)) + 1))
  606.           bodyData = quickUnion(bodyData, getSubList(data, (numCols * (i - 1)) + 2, numCols * i))
  607.         end repeat
  608.         setSelectedData(pRowHeader, rect(1, 1, 1, getAt(R, 4)), rowData)
  609.         setSelectedData(pBody, rect(1, 1, getAt(R, 3), getAt(R, 4)), bodyData)
  610.       end if
  611.     end if
  612.   end if
  613.   showEditField(_me)
  614.   return dataList
  615. end
  616.  
  617. on moveLeft me
  618.   if (pEditCell <> point(-1, -1)) and (getAt(pEditCell, 1) > 0) then
  619.     hideEditField(_me)
  620.     setAt(pEditCell, 1, getAt(pEditCell, 1) - 1)
  621.     setSelectionRect(_me, pEditCell, pEditCell)
  622.     set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  623.     updateStage()
  624.     showEditField(_me)
  625.   end if
  626.   return me
  627. end
  628.  
  629. on moveUp me
  630.   if pColumnIsVisible then
  631.     canStillGoUp = getAt(pEditCell, 2) > 0
  632.   else
  633.     canStillGoUp = getAt(pEditCell, 2) > 1
  634.   end if
  635.   if (pEditCell <> point(-1, -1)) and canStillGoUp then
  636.     hideEditField(_me)
  637.     setAt(pEditCell, 2, getAt(pEditCell, 2) - 1)
  638.     setSelectionRect(_me, pEditCell, pEditCell)
  639.     set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  640.     updateStage()
  641.     if getAt(pEditCell, 2) < getTopRow(pBody) then
  642.       simulateClickOn(pUpButton)
  643.     end if
  644.     showEditField(_me)
  645.   end if
  646.   return me
  647. end
  648.  
  649. on MoveRight me
  650.   if (pEditCell <> point(-1, -1)) and (getAt(pEditCell, 1) < getNumColumns(pBody)) then
  651.     hideEditField(_me)
  652.     setAt(pEditCell, 1, getAt(pEditCell, 1) + 1)
  653.     setSelectionRect(_me, pEditCell, pEditCell)
  654.     set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  655.     updateStage()
  656.     showEditField(_me)
  657.   end if
  658.   return me
  659. end
  660.  
  661. on moveDown me
  662.   if (pEditCell <> point(-1, -1)) and (getAt(pEditCell, 2) < getNumRows(pBody)) then
  663.     hideEditField(_me)
  664.     setAt(pEditCell, 2, getAt(pEditCell, 2) + 1)
  665.     setSelectionRect(_me, pEditCell, pEditCell)
  666.     set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
  667.     updateStage()
  668.     if getAt(pEditCell, 2) > getBottomRow(pBody) then
  669.       simulateClickOn(pDownButton)
  670.     end if
  671.     showEditField(_me)
  672.   end if
  673.   return me
  674. end
  675.